<?php
namespace App\Service\CommodityService;

use App\Service\BaseService;
use App\Service\Code\Normal;
use App\Model\CommodityModel\ThirdPartyPlatform;

/**
 * 三方供应商平台查询服务
 *
 * @author chenyun
 */
class ThirdPartyPlatformService extends BaseService
{

    const CACHE_KEY = 'third_party_platform_query_';

    /**
     * 三方授权平台批量查询服务
     *
     * @param array $param            
     * @return mixed
     */
    public function QueryThirdPartyPlatformList(array $param = [])
    {
        $where = [];
        if(isset($param["ThirdPartyPlatformName"])){
            $where[]=["ThirdPartyPlatformName","=",$param["ThirdPartyPlatformName"]];
        }

        if(isset($param["ThirdPartyPlatformCode"])){
            $where[]=["ThirdPartyPlatformCode","=",$param['ThirdPartyPlatformCode']];
        }

        $resultThirdPartyPlatformList = ThirdPartyPlatform::instance()->select([
            'ThirdPartyPlatformName as Name',
            'ThirdPartyPlatformCode as Code',
            'DefaultJsonBody',
        ])->where($where)->where('IsDeleted',0)->get()->toArray();
        foreach ($resultThirdPartyPlatformList as $key => $TripartitePlatformList){
            $resultThirdPartyPlatformList[$key]["DefaultJsonBody"] = json_decode($TripartitePlatformList["DefaultJsonBody"],true);
        }
        return Normal::returnCode(Normal::SUC,"获取成功",$resultThirdPartyPlatformList);
    }
}